package com.itserver.service.article.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itserver.mapper.art.ArticleCateMapper;
import com.itserver.pojo.PageResult;
import com.itserver.pojo.article.ArticleCate;
import com.itserver.pojo.article.QueryArticleCate;
import com.itserver.service.article.ArticleCateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ArticleCateServiceImpl implements ArticleCateService {

    @Autowired
    private ArticleCateMapper articleCateMapper;
    @Override
    public PageResult<ArticleCate> list(QueryArticleCate params) {
        PageHelper.startPage(params.getPage(), params.getPageSize());
        List<ArticleCate> rows = articleCateMapper.list(params);
        Page<ArticleCate> page = (Page<ArticleCate>) rows;
        return new PageResult<>(page.getTotal(), rows);
    }

    @Override
    public void add(ArticleCate articleCate) {
        articleCateMapper.add(articleCate);
    }

    @Override
    public void deleteById(List<Integer> ids) {
        articleCateMapper.deleteById(ids);
    }

    @Override
    public void update(ArticleCate articleCate) {
        articleCateMapper.update(articleCate);
    }
}
